<?php
defined('IN_TS') or die('Access Denied.');

$userid = aac('user')->isLogin();

$planid	= intval($_POST['planid']);
$content	= tsClean($_POST['content']);

$text = strip_tags($_POST['content'],'<img>');

if($text == ''){
	tsNotice('评论内容不能为空');
}


if($TS_USER['isadmin']==0){
	//过滤内容开始
	aac('system')->antiWord($content);
	//过滤内容结束
}

$commentid = $new['plan']->create('plan_comment',array(
	'planid'			=> $planid,
	'userid'			=> $userid,
	'content'	=> $content,
	'addtime'		=> time(),
));

$strPlan = $new['plan']->getPlanByPlanid($planid);
if($strPlan['userid'] != $TS_USER['userid']){
	$msg_userid = '0';
	$msg_touserid = $strPlan['userid'];
	$msg_content = '你发布的方案《'.$strPlan['title'].'》新增一条评论，快去看看吧^_^ ';
	$msg_tourl = tsUrl('plan','show',array('id'=>$planid));
	aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
}

header("Location: ".tsUrl('plan','show',array('id'=>$planid)));